﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using org.smslib.modem;
using java.util;
using java.util.concurrent;
using org.smslib.queues;

namespace org.smslib.modem
{
    public class MyQueue : org.smslib.queues.AbstractQueueManager
    {
        private Map queueMap;


        public override int delayedQueueSize(string str)
        {
            throw new NotImplementedException();
        }

        public override java.util.Collection getDelayedMessages()
        {
            throw new NotImplementedException();
        }

       

        public override int pendingQueueSize(string str)
        {
            throw new NotImplementedException();
        }

        public override OutboundMessage pollDelayedMessage()
        {
            throw new NotImplementedException();
        }

        public override OutboundMessage pollPendingMessage(string str)
        {
            throw new NotImplementedException();
        }

        public override bool queueMessage(OutboundMessage om)
        {
            PriorityBlockingQueue priorityBlockingQueue = (PriorityBlockingQueue)this.queueMap.get(om.getGatewayId());
            if (priorityBlockingQueue == null)
            {

                priorityBlockingQueue = new PriorityBlockingQueue(50, new PriorityComparator(this));
                this.queueMap.put(om.getGatewayId(), priorityBlockingQueue);
            }
            int num = priorityBlockingQueue.add(om) ? 1 : 0;

            return num != 0;
        }
        public override Collection getPendingMessages(string gatewayId)
        {
            PriorityBlockingQueue priorityBlockingQueue = (PriorityBlockingQueue)this.queueMap.get(gatewayId);
            if (priorityBlockingQueue == null)
            {
                return new ArrayList();
            }
            return new ArrayList(priorityBlockingQueue);
        }

        public override bool removeAllDelayedMessages()
        {
            throw new NotImplementedException();
        }

        public override bool removeAllPendingMessages()
        {
            throw new NotImplementedException();
        }

        public override bool removeAllPendingMessages(string str)
        {
            throw new NotImplementedException();
        }

        public override bool removeDelayedMessage(string str)
        {
            throw new NotImplementedException();
        }

        public override bool removeDelayedMessage(OutboundMessage om)
        {
            throw new NotImplementedException();
        }

        public override bool removePendingMessage(string str)
        {
            throw new NotImplementedException();
        }

        public override bool removePendingMessage(OutboundMessage om)
        {
            throw new NotImplementedException();
        }
    }
    internal sealed class PriorityComparator : Object, Comparator
    {



        internal PriorityComparator(MyQueue defaultQueueManager)
        {
        }

        public  int compare(OutboundMessage outboundMessage, OutboundMessage outboundMessage2)
        {
            int num = outboundMessage2.getPriority() - outboundMessage.getPriority();
            if (num == 0)
            {
                num = outboundMessage.getDate().compareTo(outboundMessage2.getDate());
            }
            return num;
        }

        public  int compare(object obj, object obj2)
        {
            return this.compare((OutboundMessage)obj, (OutboundMessage)obj2);
        }




        public bool equals(object obj)
        {
            return Object.Equals(this, obj);
        }
    }

    //public class DTGS800AModemDriver : AModemDriver
    //{

    //    protected override void clear()
    //    {
    //        base.clearBuffer();
    //    }



    //    protected override void disconnectPort()
    //    {
    //        base.disconnect();
    //    }


    //    public override object getSYNCCommander()
    //    {
    //        return base.getSYNCCommander();
    //    }
    //}
}
